<?php

namespace App\Console\Commands;

use App\model\Workshop;
use App\Repository\WorkShopRepository;
use Illuminate\Console\Command;

class WorkshopAllmap extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'workshop:map';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';
    protected $repository;
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(WorkShopRepository $repository)
    {
        $this->repository=$repository;
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Workshop::chunk(100,function($workshop){
            foreach ($workshop as $item){
                sleep(1);
               $result= $this->repository->DiskSourceGeo($item);
               $this->info($result);
                $this->info($item->id);
            }
        });
    }
}
